#include<iostream>
#include<string>
using namespace std;

int main()
{
	string str = "a doog  elpmaxe";
	reverse(str.begin(), str.end());
	cout << str << endl;
	return 0;
}


class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
        vector<int> result;
        int end = nums.size() - 1;
        int begin = 0;
        int tmp = target;
        while (begin < end)
        {
            if (nums[begin] + nums[end] > target)
            {
                end--;
            }
            else if (nums[begin] + nums[end] < target)
            {
                begin++;
            }
            else
            {
                result.push_back(nums[begin]);
                result.push_back(nums[end]);
                break;
            }
        }

        return result;

    }
};


class Solution {
public:
    string reverseWords(string s) {
        string result;
        int j = s.size() - 1;
        for (; j >= 0; --j)
        {
            if (s[j] == ' ')
            {
                continue;
            }
            int i = j;
            while (i >= 0 && s[i] != ' ')
            {
                i--;
            }
            result.append(s.substr(i + 1, j - i));
            result.append(" ");
            j = i;
        }
        if (!result.empty())
        {
            result.pop_back();
        }

        return result;

    }
};



class CQueue {
private:
    stack<int> push_stack;
    stack<int> pop_stack;
public:
    CQueue() {

    }

    void appendTail(int value) {
        if (push_stack.empty() && !pop_stack.empty())
        {
            while (!pop_stack.empty())
            {
                push_stack.push(pop_stack.top());
                pop_stack.pop();
            }
        }
        push_stack.push(value);

    }

    int deleteHead() {
        if (push_stack.empty() && pop_stack.empty())
        {
            return -1;
        }
        else if (!pop_stack.empty())
        {
            int del = pop_stack.top();
            pop_stack.pop();
            return del;
        }
        else if (!push_stack.empty())
        {
            while (!push_stack.empty())
            {
                pop_stack.push(push_stack.top());
                push_stack.pop();
            }
            int del = pop_stack.top();
            pop_stack.pop();
            return del;
        }
        return -1;
    }
};

/**
 * Your CQueue object will be instantiated and called as such:
 * CQueue* obj = new CQueue();
 * obj->appendTail(value);
 * int param_2 = obj->deleteHead();
 */